|
The IEEE 754-2008 standard includes an encoding format for decimal floating point numbers in which the significand and the exponent (and the payloads of NaNs) can be encoded in two ways, referred to in the draft as binary encoding and decimal encoding.〔(【引用サイトリンク】 date = 2006-10-04 )〕 Both formats break a number down into a sign bit ''s'', an exponent ''q'' (between ''q''min and ''q''max), and a ''p''-digit significand ''c'' (between 0 and 10''p''−1). The value encoded is (−1)''s''×10''q''×''c''. In both formats the range of possible values is identical, but they differ in how the significand ''c'' is represented. In the decimal encoding, it is encoded as a series of ''p'' decimal digits (using the densely packed decimal encoding. This makes conversion to decimal form efficient, but requires a specialized decimal ALU to process. In the binary integer decimal encoding, it is encoded as a binary number. ==Format== Using the fact that 210 = 1024 is only slightly more than 103 = 1000, 3''n''-digit decimal numbers can be efficiently packed into 10''n'' binary bits. However, the IEEE formats have significands of 3''n''+1 digits, which would generally require 10''n''+4 binary bits to represent. This would not be efficient, because only 10 of the 16 possible values of the additional 4 bits are needed. A more efficient encoding can be designed using the fact that the exponent range is of the form 3×2''k'', so the exponent never starts with 11 . Using the Decimal32 encoding (with a significand of 3*2+1 decimal digits) as an example ( e stands for exponent, m for mantissa, i.e. significand):* If the significand starts with 0mmm , omitting the leading 0 bit lets the significand fit into 23 bits:s 00eeeeee (0)mmm mmmmmmmmmm mmmmmmmmmm s 01eeeeee (0)mmm mmmmmmmmmm mmmmmmmmmm s 10eeeeee (0)mmm mmmmmmmmmm mmmmmmmmmm * If the significand starts with 100m , omitting the leading 100 bits lets the significand fit into 21 bits. The exponent is shifted over 2 bits, and a 11 bit pair shows that this form is being used:s 1100eeeeee (100)m mmmmmmmmmm mmmmmmmmmm s 1101eeeeee (100)m mmmmmmmmmm mmmmmmmmmm s 1110eeeeee (100)m mmmmmmmmmm mmmmmmmmmm * Infinity, quiet NaN and signaling NaN use encodings beginning with s 1111 :s 11110 xxxxxxxxxxxxxxxxxxxxxxxxxx s 111110 xxxxxxxxxxxxxxxxxxxxxxxxx s 111111 xxxxxxxxxxxxxxxxxxxxxxxxx The bits shown in parentheses are ''implicit'': they are not included in the 32 bits of the Decimal32 encoding, but are implied by the two bits after the sign bit. The Decimal64 and Decimal128 encodings have larger exponent and significand fields, but operate in a similar fashion. For the Decimal128 encoding, 113 bits of significand is actually enough to encode 34 decimal digits, and the second form is never actually required. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Binary Integer Decimal」の詳細全文を読む スポンサード リンク
|